package com.linewell.mongodemo.pojo;

import org.hibernate.validator.constraints.Length;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.UUID;



public class Detail implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 8149985648699864753L;
	
	/**
	 * 唯一标识
	 */
	@Id
	private String id;
	/**
	 * 字段名（注释）
	 */
	@NotNull
	@Length(min=1,max=255)
	@Field("t_name")
	private String tName;
	/**
	 * 字段值
	 */
	@Field("detail_value")
	private String detailValue;
	/**
	 * 字段英文名
	 */
	@NotNull
	@Length(min=1,max=20)
	@Field("t_value")
	private String tValue;
	/**
	 * 字段类型
	 */
	@NotNull
	@Length(min=1,max=15)
	@Field("t_type")
	private String tType;
	/**
	 * 字段长度
	 */
	@Min(0) 
	@Max(1000) 
	@Field("t_length")
	private Integer tLength;
	/**
	 * 字段固值
	 */
	@Length(min=0,max=100)
	@Field("t_guzhi")
	private String tGuzhi;
	/**
	 * 是否必填（0：否，1：是）
	 */
	@NotNull
	@Min(0) 
	@Max(1) 
	@Field("t_required")
	private Integer tRequired;
	/**
	 * 排序
	 */
	@NotNull
	@Min(0) 
	@Max(200)
	@Field("sortno")
	private Integer sortno;
    /**
     * 第几行
     */
	@Field("rowno")
    private Integer rowno;

	/**
	 * 选项内容
	 */
	@Length(min=0,max=1000)
	@Field("t_content")
	private String tContent;
	
	public Detail(Detail detail, String detailValue, Integer rowno, String tContent) {
		this.id = UUID.randomUUID().toString().replace("-","");
		this.detailValue = detailValue;
		if("guzhi".equals(detail.gettType())){
			this.detailValue = detail.gettGuzhi();
		}
		
		this.tName = detail.gettName();
		this.tValue = detail.gettValue();
		this.tType = detail.gettType();
		this.tRequired = detail.gettRequired() ;
		this.tLength = detail.gettLength();
		this.tGuzhi = detail.gettGuzhi() ;
		this.rowno = rowno;
		this.sortno = detail.getSortno();
		this.tContent = tContent;
	}
    
	
	public Detail() {
		super();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String gettName() {
		return tName;
	}

	public void settName(String tName) {
		this.tName = tName;
	}

	public String gettValue() {
		return tValue;
	}

	public void settValue(String tValue) {
		this.tValue = tValue;
	}

	public String gettType() {
		return tType;
	}

	public void settType(String tType) {
		this.tType = tType;
	}

	public Integer gettLength() {
		return tLength;
	}

	public void settLength(Integer tLength) {
		this.tLength = tLength;
	}

	public String gettGuzhi() {
		return tGuzhi;
	}

	public void settGuzhi(String tGuzhi) {
		this.tGuzhi = tGuzhi;
	}

	public Integer gettRequired() {
		return tRequired;
	}

	public void settRequired(Integer tRequired) {
		this.tRequired = tRequired;
	}


	public String getDetailValue() {
		return detailValue;
	}

	public void setDetailValue(String detailValue) {
		this.detailValue = detailValue;
	}

	public Integer getRowno() {
		return rowno;
	}

	public void setRowno(Integer rowno) {
		this.rowno = rowno;
	}

	public void setSortno(Integer sortno) {
		this.sortno = sortno;
	}

	public Integer getSortno() {
		return sortno;
	}

	public String gettContent() {
		return tContent;
	}

	public void settContent(String tContent) {
		this.tContent = tContent;
	}
	
}
